package com.alfred.springboot.globalexceptionhandle.handler;

import com.alfred.springboot.globalexceptionhandle.bean.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author: alfred
 * @date: 2021/7/20
 * @description: 全局异常处理类
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(NullPointerException.class)
    public Result argExceptionHandler(NullPointerException e) {
        log.error("发生空指针异常", e);
        return Result.builder().code(0L).message("null point").build();
    }

}
